#include<func.h>
//使用了SA_RESTART标志后,程序阻塞在系统调用，信号处理完毕之后，从阻塞的系统返回
void sigfunc(int signum,siginfo_t *p,void *p1)
{
    printf("sig %d is coming\n",signum);
}

int main()
{
    struct sigaction act;//定义结构体
    bzero(&act,sizeof(act));//清空
    act.sa_sigaction =sigfunc; //把信号处理函数赋给sa_sigaction
    act.sa_flags=SA_SIGINFO|SA_RESTART;//标识sa_sigaction生效
    int ret=sigaction(SIGINT,&act,NULL);
    ERROR_CHECK(ret,-1,"sigaction");
    char buf[128]={0};
    ret=read(STDIN_FILENO,buf,sizeof(buf));//读取标准输入
    ERROR_CHECK(ret,-1,"read");
    printf("ret=%d,buf=%s\n",ret,buf);
    return 0;
}